package com.xmcowell.sportpacemaster.utils.mqtt;

import android.content.Context;

import com.google.gson.Gson;
import com.xmcowell.sportpacemaster.config.Contents;
import com.xmcowell.sportpacemaster.utils.PreferencesUtils;

import java.util.ArrayList;

public class MyMqttSet {
    private static ArrayList<String> listTopic;

    /**
     * 设置接收信息的唯一标识
     *
     * @param userId
     */
    public static void set_mark(Context context, String userId) {
        listTopic = new ArrayList<String>();
        listTopic.add(userId);
//        listTopic.add(userId + Contents.TOPIC_PERSONNEL);
//        listTopic.add(userId + Contents.TOPIC_PRAISE);
        Gson gson = new Gson();
        String json = gson.toJson(listTopic);

        PreferencesUtils.putValueToSPMap(context, PreferencesUtils.Keys.TOPIC, json);

    }

    /**
     * 开启mqtt服务
     *
     * @param context
     */
    public static void start_PushService(Context context,String topic) {
//        set_mark(context, Contents.IMEI);
        set_mark(context,topic);
        PushService.actionStart(context.getApplicationContext());
    }

    /**
     * 停止mqtt服务
     *
     * @param context
     */
    public static void stop_PushService(Context context) {
        PushService.actionStop(context.getApplicationContext());
    }


}
